﻿
<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Login</title>
    <script src="~/Scripts/jquery-1.10.2.min.js"></script>
    <script src="~/Scripts/login.js"></script>
    <script>
        $(function () {
                alert("由于授权原因，layui代码将不再公开，请谅解。");
                $(document).on('click', '#btnLogin', function () {
                    $.post('/userlogin', { username: $('#txtUserName').val(), password: $('#txtUserPwd').val() }, function (result) {
                        if (result.code == 0) {
                            var uid = result.data.userid;
                            if (uid <= 0) {
                                alert('用户名或者密码错误');
                            } else {
                                localStorage.setItem('currentUserId', uid);
                                location.href = '/';
                            }
                        } else {

                            alert(result.msg);
                        }
                    });
                });
        });
    </script>
</head>
<body>
   <input type="text" placeholder="User Name" id="txtUserName"/>
    <input type="password" placeholder="Password" id="txtUserPwd"/>
    <input type="button" id="btnLogin" value="Login"/>
</body>
</html>
